Java: A Beginner’s Guide by Herbert Schildt
Author:Herbert Schildt [Schildt, Herbert]
Language: eng
Format: epub
Publisher: McGraw-Hill
Published: 2012-06-09T07:00:00+00:00
Try Blocks Can Be Nested
One try block can be nested within another. An exception generated within the inner try block that is not caught by a catch associated with that try is propagated to the outer try block. For example, here the ArrayIndexOutOfBoundsException is not caught by the inner catch, but by the outer catch:
In this example, an exception that can be handled by the inner try—in this case, a divide-by-zero error—allows the program to continue. However, an array boundary error is caught by the outer try, which causes the program to terminate.
Although certainly not the only reason for nested try statements, the preceding program makes an important point that can be generalized. Often nested try blocks are used to allow different categories of errors to be handled in different ways. Some types of errors are catastrophic and cannot be fixed. Some are minor and can be handled immediately. Many programmers use an outer try block to catch the most severe errors, allowing inner try blocks to handle less serious ones.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
POP by Steven Heller(3214)
Japanese Design by Patricia J. Graham(2976)
The Power of Broke by Daymond John(2741)
Architecture 101 by Nicole Bridge(2684)
Indistractable: How to Control Your Attention and Choose Your Life by Nir Eyal(2258)
Fusion 360 for Makers by Lydia Sloan Cline(2219)
Actionable Gamification: Beyond Points, Badges, and Leaderboards by Yu-kai Chou(2055)
Batik by Rudolf Smend(1990)
Origami Art by Michael G. Lafosse & Richard L. Alexander(1986)
Homebody by Joanna Gaines(1971)
Whiskey in a Teacup by Reese Witherspoon(1855)
Feng Shui by Stephen Skinner(1845)
Worn in New York by Emily Spivack(1826)
Austin Kleon by Steal Like an Artist(1804)
Simple Gatherings by Melissa Michaels(1767)
Don't Make Me Think, Revisited: A Common Sense Approach to Web Usability by Steve Krug(1760)
Hygge: The Danish Art of Happiness by Marie Tourell Søderberg(1628)
The Joy of Hygge by Jonny Jackson(1597)
The Laws of Simplicity by John Maeda(1504)
